package xyz.xpman.prisonerfitness.service;

import android.annotation.SuppressLint;
import android.content.Context;

import androidx.annotation.Nullable;

import org.jetbrains.annotations.NotNull;

import java.time.LocalDate;
import java.util.List;

import xyz.xpman.prisonerfitness.entity.TrainingRecord;

@SuppressWarnings("unused")
public class TrainingRecordService {
    private static TrainingRecord DAO;
    @SuppressLint("StaticFieldLeak")
    public static TrainingRecordService ME = null;
    @SuppressLint("StaticFieldLeak")
    private static boolean init = false;


    private TrainingRecordService() { }


    public static void init(@Nullable Context context) {
        if (!init && context != null) {

            TrainingRecord.init(context);

            DAO = new TrainingRecord();
            ME = new TrainingRecordService();

            init = true;
        }
    }


    // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -


    public TrainingRecord findById(@NotNull String id) {
        return DAO.findById(id);
    }

    public @NotNull List<TrainingRecord> findByDate(@NotNull LocalDate date) {
        return DAO.findByDate(date);
    }

    public int countTrainingTime() {
        return DAO.countTrainingTime();
    }

    public int countTrainingDays() {
        return DAO.countTrainingDay();
    }

    public int countTrainingTimes() {
        return DAO.countTrainingTimes();
    }

    public List<TrainingRecord> findAll() {
        return DAO.findAll();
    }


    public boolean save(@NotNull TrainingRecord model) {
        return model.add();
    }

    public boolean update(@NotNull TrainingRecord model) {
        return model.update();
    }


}
